<template>
  <div class="revenueDetails">
    <PullRefresh v-model="loading" @refresh="onRefresh">
      <van-list
        :loading="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <div
          class="product-list-block-wrap"
          :class="{ 'product-list-grad-wrap': type === 'grid' }"
        >
          <Item v-for="(item, index) in list" :key="index" :item="item" />
        </div>
      </van-list>
    </PullRefresh>
  </div>
</template>
  <script setup>
import { PullRefresh } from "vant";
import { ref, onMounted } from "vue";
import Item from "./item.vue";
import request from "@/utils/request";
const list = ref([]);
const loading = ref(true);
const finished = ref(false);
const pageParams = {
  page: 1,
  pageSize: 15,
};
const onLoad = () => {
  getList(false);
};
const onRefresh = () => {
  getList(true);
};
const getList = (refresh) => {
  if (refresh) {
    pageParams.page = 1;
  } else {
    pageParams.page++;
  }
  loading.value = true;
  finished.value = false;
  request({
    url: "App/api/IncomeDetail",
    method: "POST",
    data: {
      ...pageParams,
    },
  }).then((res) => {
    loading.value = false;
    if (refresh) {
      list.value = res.data.data;
    } else {
      list.value = list.value.concat(res.data.data);
    }
    if (res.data.data.length == 0) {
      finished.value = true;
    }
  });
};
onMounted(() => {
  onRefresh();
});
</script>
  
  <style lang="scss" scoped>
.product-list-block-wrap {
  padding-top: 10px;
}
.revenueDetails{
    background-color: #f2f2f2;
    min-height: 100vh;
}
</style>